<!-- 管点管理 -->
<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form-model layout="inline">
        <a-row :gutter="24">
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="所属区域">
              <j-select-depart placeholder="请选择区域" v-model="queryParam.areaId" />
            </a-form-model-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="管点类型">
              <j-dict-select-tag
                placeholder="请选择管点类型"
                v-model="queryParam.pipType"
                dictCode="ps_pip_point_type"
              />
            </a-form-model-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="管点编号">
              <a-input v-model="pipNo"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="关联点位编号">
              <a-input v-model="queryParam.associationPosPointNo"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="管点缺陷">
              <j-dict-select-tag
                type="list"
                v-model="queryParam.pipPointDefective"
                dictCode="ps_point_defective"
                placeholder="请选择管点缺陷"
              />
            </a-form-model-item>
          </a-col>
          <a-col :xl="5" :lg="7" :md="8" :sm="24">
            <a-form-model-item label="道路">
              <a-input v-model="queryParam.street" placeholer="请输入"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :xl="4" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" style="margin: 0 auto 10px"> 查询 </a-button>
              <a-button style="margin-left: 10px" @click="customerSearchReset"> 重置 </a-button>
            </span>
          </a-col>
        </a-row>
      </a-form-model>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
      <a-upload
        name="file"
        :showUploadList="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-button type="primary" icon="download" @click="handleExportXls('管点表')">导出</a-button>
      <!-- <a-upload
        name="file"
        :showUploadList="false"
        :headers="tokenHeader"
        :action="importProgressExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入工程进度</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <!--      <j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query>-->
      <!--      <a-dropdown v-if="selectedRowKeys.length > 0">-->
      <!--        <a-menu slot="overlay">-->
      <!--          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>-->
      <!--        </a-menu>-->
      <!--        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>-->
      <!--      </a-dropdown>-->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
    <pip-point-modal ref="modalForm" @ok="modalFormOk"></pip-point-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
// import PipPointModal from './modules/PipPointModal'
import PipPointModal from '@views/modules/PipPoint/PipPointModal'
import { getAction } from '@api/manage'

import { filterDictTextByCache } from '@/components/dict/JDictSelectUtil'
import { getDictItemListByCode } from '@/api/system.js'

export default {
  name: 'PipPointList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    PipPointModal,
  },
  data() {
    return {
      pipNo: '',
      description: '管点表管理页面',
      // 表头
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: (t, r, index) => {
            const { pageSize, current } = this.ipagination
            return (current - 1) * pageSize + parseInt(index) + 1
          },
        },
        {
          title: '管点名称',
          align: 'center',
          dataIndex: 'pipName',
        },
        {
          title: '管点编号',
          align: 'center',
          dataIndex: 'pipNo',
        },
        {
          title: '管点类型',
          align: 'center',
          dataIndex: 'pipType',
          customRender: (text, record, index) => {
            return filterDictTextByCache('ps_pip_point_type', text) || '--'
          },
        },
        {
          title: '区域',
          align: 'center',
          dataIndex: 'areaId_dictText',
        },
        {
          title: '井盖形状',
          align: 'center',
          dataIndex: 'manholeCoveShape',
          customRender: (text, record, index) => {
            return filterDictTextByCache('ps_manholecovet_shape', text) || '--'
          },
        },
        {
          title: '井盖材质',
          align: 'center',
          dataIndex: 'manholeCoveMaterial',
          customRender: (text, record, index) => {
            return filterDictTextByCache('ps_manholecove_material', text) || '--'
          },
        },
        {
          title: '高程',
          align: 'center',
          dataIndex: 'dsm',
        },
        {
          title: '经度',
          align: 'center',
          dataIndex: 'longitude',
        },
        {
          title: '纬度',
          align: 'center',
          dataIndex: 'latitude',
        },
        {
          title: '管点缺陷',
          align: 'center',
          dataIndex: 'pipPointDefective',
          customRender: (text, record, index) => {
            return filterDictTextByCache('ps_point_defective', text) || '--'
          },
        },
        {
          title: '井深(m)',
          align: 'center',
          dataIndex: 'measureDepth',
        },
        {
          title: '道路',
          align: 'center',
          dataIndex: 'street',
        },
        {
          title: '关联点位编号',
          align: 'center',
          dataIndex: 'associationPosPointNo',
        },
        {
          title: '状态',
          align: 'center',
          dataIndex: 'status',
          customRender: (text, record, index) => (text ? (text == 1 ? '规划' : '现状') : ''),
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      url: {
        list: '/paishui/pipPoint/list',
        delete: '/paishui/pipPoint/delete',
        deleteBatch: '/paishui/pipPoint/deleteBatch',
        exportXlsUrl: '/paishui/pipPoint/exportXls',
        importExcelUrl: 'paishui/import/excel/easyIpt',
        importProgressExcelUrl: 'paishui/geophysical/excel/easyIpt',
      },
      dictOptions: {},
      superFieldList: [],
      title: '编辑',
      visible: false,
      labelCol: { span: 4 },
      wrapperCol: { span: 14 },
      pipPointDefectiveList: [],
    }
  },
  created() {
    // this.getSuperFieldList();
  },
  watch: {
    pipNo(pipNo) {
      if (pipNo) {
        this.queryParam.pipNo = `*${pipNo}*`
      } else {
        this.queryParam.pipNo = ''
      }
    },
  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    },
    importProgressExcelUrl: function () {
      return `${window._CONFIG['domianURL']}/${this.url.importProgressExcelUrl}`
    },
  },
  methods: {
    customerSearchReset() {
      this.pipNo = ''
      this.searchReset()
    },
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'int', value: 'version', text: '版本号', dictCode: '' })
      fieldList.push({ type: 'int', value: 'deleted', text: '是否删除', dictCode: '' })
      fieldList.push({ type: 'string', value: 'pipName', text: '管点名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'pipNo', text: '管点编号', dictCode: '' })
      fieldList.push({ type: 'int', value: 'pipPointDefective', text: '管点缺陷', dictCode: 'ps_point_defective' })
      fieldList.push({ type: 'int', value: 'pipType', text: '管点类型 1雨水井 2污水井', dictCode: '' })
      fieldList.push({ type: 'string', value: 'associationPosPointNo', text: '关联点位编号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'associationPosPoint', text: '关联点位id', dictCode: '' })
      fieldList.push({ type: 'string', value: 'areaId', text: '所属区域id', dictCode: '' })
      fieldList.push({ type: 'string', value: 'areaName', text: '所属区域', dictCode: '' })
      fieldList.push({ type: 'string', value: 'dsm', text: '地面高程', dictCode: '' })
      fieldList.push({ type: 'string', value: 'arcgis', text: 'ArcGis编号', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'longitude', text: '经度', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'latitude', text: '纬度', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'geophysicaLongitude', text: '物探经度', dictCode: '' })
      fieldList.push({ type: 'BigDecimal', value: 'geophysicaLatitude', text: '物探纬度', dictCode: '' })
      fieldList.push({ type: 'string', value: 'remark', text: '备注', dictCode: '' })
      fieldList.push({ type: 'int', value: 'posStatus', text: '状态 1现状 2规划', dictCode: '' })
      this.superFieldList = fieldList
    },
  },
}
</script>
<style scoped>
@import '~@assets/less/common.less';
.ant-row-flex >>> .ant-col-6 {
  width: 10%;
}
.ant-row >>> .ant-col-4 {
  width: 36.666667%;
}
.search {
  margin-bottom: 25px;
}
.form_add >>> .ant-form-item {
  display: flex;
}
.form_temperatureData >>> .ant-form-item-control-wrapper,
.form_areaId >>> .ant-form-item-control-wrapper {
  width: 186px;
}
</style>
